home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 37 / Amiga Format CD37 (1999-02-16)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-03].iso / -screenplay- / shareware / invasionforce / source / includes / global.h < prev    next >
C/C++ Source or Header  |  1999-01-09  |  16KB  |  445 lines

  1. // global.h -- global definitions header
  2.  
  3. // various types of headers
  4. #include <dos/dos.h>
  5. #include <intuition/intuition.h>
  6. #include <intuition/screens.h>
  7. #include <intuition/gadgetclass.h>
  8. #include <libraries/gadtools.h>
  9. #include <libraries/asl.h>
  10.  
  11. #include <clib/exec_protos.h>
  12. #include <clib/graphics_protos.h>
  13. #include <clib/intuition_protos.h>
  14. #include <clib/gadtools_protos.h>
  15.  
  16. #include <exec/memory.h>
  17.  
  18. #include <proto/intuition.h>
  19. #include <proto/dos.h>
  20. #include <proto/exec.h>
  21. #include <proto/diskfont.h>
  22. #include <proto/graphics.h>
  23. #include <proto/gadtools.h>
  24. #include <proto/asl.h>
  25.  
  26. #include <stdlib.h>
  27. #include <stdio.h>
  28. #include <time.h>
  29. #include <string.h>
  30.  
  31. #undef strcpy
  32.  
  33. #include <libraries/reqtools.h>
  34. #include <proto/reqtools.h>
  35.  
  36. // These make the code easier to follow.
  37. #define FI }
  38. #define OD }
  39. #define Bool(a) ((a)!=0)   // explicitly converts any numeric or bit value
  40.                            // to TRUE or FALSE
  41.  
  42. // sound and music support
  43. #include "sound_protos.h"
  44. #include "libproto.h"
  45.  
  46. // These common default tags for my EZ Requesters
  47. #define RT_DEFAULT RT_Window,map_window,RT_ReqPos,REQPOS_CENTERWIN,RT_LockWindow,TRUE
  48.  
  49. #define IDCMP_MAPEDIT (IDCMP_MENUPICK|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE|SCROLLERIDCMP|IDCMP_RAWKEY|IDCMP_VANILLAKEY)
  50. #define IDCMP_PLAYGAME (IDCMP_MENUPICK|IDCMP_MOUSEBUTTONS|SCROLLERIDCMP|IDCMP_RAWKEY|IDCMP_VANILLAKEY|IDCMP_INTUITICKS)
  51.  
  52. extern ULONG __far RangeSeed;  // This is needed for random number generation.
  53.  
  54. // the parameters that get me a standard busy pointer
  55. #define BUSY_POINTER busy_pointer_data,16,16,-6,0
  56.  
  57. // locations of the special map objects in my graphics bitmap
  58. #define MAP_CURSOR 242,30
  59. #define MAP_MARKER 242,48
  60. #define MAP_BLAST 154,30
  61.  
  62. // pen colors
  63. #define LT_GRAY   0
  64. #define BLACK     1
  65. #define WHITE     2
  66. #define LT_BLUE   3
  67. #define TAN       4
  68. #define DK_GRAY   5
  69. #define PURPLE    6
  70. #define ORANGE    7
  71. #define RED       8
  72. #define DK_BLUE   9
  73. #define BLUE      10
  74. #define BROWN     11
  75. #define GRAY      12
  76. #define DK_GREEN  13
  77. #define LT_GREEN  14
  78. #define GREEN     15
  79.  
  80. // terrain hex ID codes
  81. #define HEX_UNEXPLORED  0
  82. #define HEX_PLAINS      1
  83. #define HEX_DESERT      2
  84. #define HEX_FORBID      3
  85. #define HEX_ARCTIC      3
  86. #define HEX_BRUSH       4
  87. #define HEX_FOREST      5
  88. #define HEX_JUNGLE      6
  89. #define HEX_RUGGED      7
  90. #define HEX_HILLS       8
  91. #define HEX_MOUNTAINS   9
  92. #define HEX_PEAKS       10
  93. #define HEX_SWAMP       11
  94. #define HEX_SHALLOWS    12
  95. #define HEX_OCEAN       13
  96. #define HEX_DEPTH       14
  97. #define HEX_ICE         15
  98. #define HEX_CITY        16    // not a real hex, but a valid brush value
  99. #define HEX_ROADS       17    // ditto!
  100.  
  101. // following macro easily determines if a hex is ocean (ice doesn't count)
  102. #define OCEAN_P(a) (a>=HEX_SHALLOWS&&a<=HEX_DEPTH)
  103.  
  104. #define VALID_HEX(a,b) ((BOOL)(a>=0&&a<width&&b>=0&&b<height))
  105.  
  106. #define GRID_SIZE ((long)((width+width%2)*height/2+1))
  107.  
  108. #define ROAD 1     // flags show presence of roads or minefields
  109. #define MINE 2
  110.  
  111. // unit-icon ID codes
  112. // the first 12 are also used to identify unit types
  113. #define RIFLE        0
  114. #define ARMOR        1
  115. #define AIRCAV       2
  116. #define BOMBER       3
  117. #define FIGHTER      4
  118. #define TRANSPORT    5
  119. #define SUB          6
  120. #define DESTROYER    7
  121. #define CRUISER      8
  122. #define BATTLESHIP   9
  123. #define CARRIER      10
  124. #define AIRBASE      11
  125.  
  126. // these aren't properly unit types
  127. #define LANDMINE     17
  128. #define SEAMINE      18
  129. #define MILITIA      20
  130. #define CITY         21
  131. #define ROADS        22
  132.  
  133. // map display info
  134. // minimum width and height designed for NTSC, no overscan
  135. #define MIN_WD 19
  136. #define MIN_HT 14
  137.  
  138. // this is the visible overlap around the edges of the map when
  139. // using wrap-around
  140. #define WRAP_OVERLAP 3
  141.  
  142. extern BOOL fmail;
  143.  
  144. extern BOOL modem;
  145.  
  146. struct Hex_Coords {
  147.    short col, row;
  148. };
  149.  
  150. // global game options
  151. struct Opt {
  152.    int gametype;        // normal, file-mail, or modem
  153.    BOOL wrap;           // wrap-around map
  154.    BOOL defend_cities;  // units in a city help defend it
  155.    BOOL fortification;  // allow units to dig in?
  156.    BOOL stacking;       // none, partial (in movement), full
  157.    BOOL landmines;      // landmines enabled?
  158.    BOOL seamines;       // seamines enabled?
  159. };    // opt;
  160.  
  161. struct OldCity {     // KEPT FOR COMPATIBILITY
  162.    struct MinNode cnode;
  163.    short col, row;   // location on map
  164.    short unit_type;  // what it's producing
  165.    short unit_wip;   // Work In Progress, how much it's already built
  166.    short owner;      // who owns dis joint?
  167.    short industry;   // production capacity, defaults to 50%
  168.    APTR reserved;    // reserved for what, I just don't know
  169.    char name[20];    // name of city
  170. };
  171.  
  172. struct City {
  173.    struct MinNode cnode;
  174.    short col, row;   // location on map
  175.    short unit_type;  // what it's producing
  176.    short unit_wip;   // Work In Progress, how much it's already built
  177.    short owner;      // who owns dis joint?
  178.    short industry;   // production capacity, defaults to 50%
  179.    short specialty;  // the unit type this city specializes in,
  180.                      // or 12 (CITY) means no specialty
  181.    short reserved;
  182.    char name[20];    // name of city
  183.    UBYTE recon[9];   // recon value for each player
  184. };
  185.  
  186.  
  187. // valid order codes that can be given
  188. // each of these conditions has a graphical token associated with it
  189. #define ORDER_NONE      0
  190. #define ORDER_SENTRY    1
  191. #define ORDER_FORTIFY   2
  192. #define ORDER_FORTIFIED 3
  193. #define ORDER_LOAD      4
  194. #define ORDER_UNLOAD    5
  195. #define ORDER_GOTO      6
  196. #define ORDER_AIRBASE   7
  197.  
  198.  
  199. // These two are NOT associated with graphical tokens - use carefully
  200. #define ORDER_HOME      10
  201. #define ORDER_PATROL    11
  202.  
  203. struct OldOrder { // obsolete; intended only for compatibility purposes
  204.    short type;    // code for the type of order
  205.    short orgx,  orgy;       // origin coordinates (Quit smirking!)
  206.    short destx, desty;      // destination coordinates
  207.    short etc;     // Estimated Time of Completion; the turn number when a
  208.                   // non-movement activity will be finished, such as
  209.                   // fortification, minelaying, etc.
  210.    struct Unit *dest_unit;  // destination unit (i.e. aircraft carrier)
  211. };
  212.  
  213. struct Order {
  214.    short type;    // code for the type of order
  215.    short orgx,  orgy;       // origin coordinates (Quit smirking!)
  216.    short destx, desty;      // destination coordinates
  217.    short etc;     // Estimated Time of Completion; the turn number when a
  218.                   // non-movement activity will be finished, such as
  219.                   // fortification, minelaying, etc.
  220.    short reserved;
  221.    BOOL processed;     // flag shows whether this unit has been processed
  222.                        // by the order manager this turn
  223.    struct Unit *dest_unit;  // destination unit (i.e. aircraft carrier)
  224. };
  225.  
  226.  
  227. /*
  228.    If you change the UnitTemplate data structure, be sure to also change
  229.    the wishbook[] initialization in data_struct.c!
  230. */
  231.  
  232. struct UnitTemplate {
  233.    int type;         // type of unit to build (NOT USED)
  234.    int build;        // amount of industry units needed to build one
  235.    int range;        // number of movement units without refueling (-1 = unlimited)
  236.    int speed;        // number of movement units per turn
  237.    int hitpoints;    // number of hits it can take without being destroyed
  238.    BOOL enabled;     // available in this game, true or false
  239.    BOOL ship_flag;   // set TRUE if it can only be built in port cities
  240.    char name[20];    // name of unit type "RIFLE", "TRANSPORT", etc.
  241. };    // wishbook[12]
  242.  
  243. struct InfoTemplate {
  244.    BOOL enabled;
  245. };
  246.  
  247.  
  248. struct OldUnit {
  249.    struct MinNode unode;
  250.    short col, row;   // location of the piece
  251.    short owner;      // who owns the piece
  252.    short type;       // what kind of piece it is
  253.    short damage;     // how many hits it has taken
  254.    short attacks;    // how many attacks it has made this turn
  255.    short cargo;      // how many cargo units are on board
  256.    short move;       // how many 1/60 spaces it can move this turn
  257.    short fuel;       // how many turns remain before refueling
  258.    struct Unit *ship;     // ship that is carrying this unit or NULL
  259.    struct Order *orders;  // pointer to the piece's current orders or NULL
  260.    char *name;       // pointer to name of unit, otherwise NULL
  261. };
  262.  
  263. struct Unit {
  264.    struct MinNode unode;
  265.    short col, row;   // location of the piece
  266.    short owner;      // who owns the piece
  267.    short type;       // what kind of piece it is
  268.    short damage;     // how many hits it has taken
  269.    short attacks;    // how many attacks it has made this turn
  270.    short cargo;      // how many cargo units are on board
  271.    short weight;     // how much cargo weight it's carrying
  272.                      // (rifle=1, armor=2, fighter=1)
  273.    short move;       // how many 1/60 spaces it can move this turn
  274.    short fuel;       // how many turns remain before refueling
  275.    long reserved;
  276.    struct Unit *ship;     // ship that is carrying this unit or NULL
  277.    struct Order *orders;  // pointer to the piece's current orders or NULL
  278.    char *name;       // pointer to name of unit, otherwise NULL
  279. };
  280.  
  281.  
  282. #define mask(a) (1<<a) // used for bitwise tests
  283.  
  284. enum PlayerType { NOPLAYER, HUMAN, COMPUTER, NEUTRAL, COMP2, COMP3, AREXX };
  285. enum SoundFX { SOUND_ALL, SOUND_BATTLE, SOUND_NONE };
  286. enum PlayerStatus { ACTIVE, CRUSHED, SURRENDERED };
  287.  
  288. /*
  289.    The following flag values define possible return values of unit_readiness().
  290.    This has been changed from the previous method of using enumerated values,
  291.    because I found it might be useful for some of the states to overlap.
  292. */
  293. #define UNIT_UNREADY    1
  294. #define UNIT_READY      (1<<1)
  295. #define UNIT_ENGAGED    (1<<2)
  296. #define UNIT_PROCESSED  (1<<3)
  297.  
  298. // these were the previous values...
  299. // enum UnitStatus { UNIT_UNREADY, UNIT_READY, UNIT_ENGAGED, UNIT_PROCESSED };
  300.  
  301. #define ISHUMAN(x) (x==HUMAN)
  302. #define NONHUMAN(x) (x>=COMPUTER&&x<=AREXX)
  303.  
  304. struct OldMapIcon {     // an object to display on the user's map
  305.    struct MinNode inode;
  306.    short col, row;   // location on player's map
  307.    short type;       // icon number (or city)
  308.    short owner;      // what player it belongs to
  309.    short token;      // show order status
  310.    BOOL stacked;     // draw heavy border
  311. };
  312.  
  313. struct MapIcon {     // an object to display on the user's map
  314.    struct MinNode inode;
  315.    short col, row;   // location on player's map
  316.    short type;       // icon number (or city)
  317.    short owner;      // what player it belongs to
  318.    short token;      // show order status
  319.    short turn;       // turn number when the icon was made
  320.    BOOL stacked;     // draw heavy border
  321. };
  322.  
  323. struct OldPLayer {   // obsolete structure; kept only for compatibility
  324.    char name[41];             // the player's chosen name
  325.    char passkey[41];          // the player's encrypted password
  326.    enum PlayerType type;      // human or computer?
  327.    enum PlayerStatus status;  // active, crushed, surrendered, whatever...
  328.    short color;               // the color used to indentify his units
  329.    short prod;                // production efficiency, range 0 to 100
  330.    short att;                 // attack efficiency, range 0 to 100
  331.    short def;                 // defense efficiency, range 0 to 100
  332.    short aggr;                // computer aggressiveness, range 1 to 10
  333.    // these next few are user-set preferences
  334.    short msg_delay;           // time delay for user event messages
  335.    short battle_delay;        // time delay for combat events
  336.    enum SoundFX soundfx;      // sound effects: none, all, or battle sounds only
  337.    BOOL autorpt;              // show combat report automatically each turn?
  338.    BOOL show_production;      // automatically show new units produced (not ships)
  339.    // next two are for map data
  340.    char *map;                 // the player's personal battle map
  341.    struct MinList icons;      // list of icons to display for his map
  342.    // eud[] & uld[] store statistics for the war report, have no effect on game
  343.    short eud[11];             // Enemy Units Destroyed
  344.    short ulc[11];             // Units Lost in Combat
  345. };
  346.  
  347. /*
  348.    I have added a new value to the PLayer structure.  This is the "show" value
  349.    which determines whether game actions for this player are displayed on
  350.    screen.  Normally this will have a value of SHOW_NON for computer opponents
  351.    and SHOW_ALL for human players.  However, it is possible to add other modes
  352.    for demonstrations, debugging, etc.
  353. */
  354. #define SHOW_NON   0  // show nothing on screen: no map display, etc.
  355. #define SHOW_GRP   1  // show map display and graphics action
  356. #define SHOW_SND   2  // play sounds
  357. #define SHOW_REQ   4  // present requesters and other events requiring human input
  358. #define SHOW_ALL   (SHOW_GRP|SHOW_SND|SHOW_REQ)
  359.  
  360. struct PLayer {
  361.    char name[41];             // the player's chosen name
  362.    char passkey[41];          // the player's encrypted password
  363.    enum PlayerType type;      // human or computer?
  364.    enum PlayerStatus status;  // active, crushed, surrendered, whatever...
  365.    short show;   // display status of this player; see notes above
  366.    short color;               // the color used to indentify his units
  367.    short prod;                // production efficiency, range 0 to 100
  368.    short att;                 // attack efficiency, range 0 to 100
  369.    short def;                 // defense efficiency, range 0 to 100
  370.    short aggr;                // computer aggressiveness, range 1 to 10
  371.    short reserved1;
  372.    // these next few are user-set preferences
  373.    short snd_vol;             // sound effects volume
  374.    short msg_delay;           // time delay for user event messages
  375.    short battle_delay;        // time delay for combat events
  376.    enum SoundFX soundfx;      // sound effects: none, all, or battle sounds only
  377.    BOOL autorpt;              // show combat report automatically each turn?
  378.    BOOL show_production;      // automatically show new units produced (not ships)
  379.    // next two are for map data
  380.    char *map;                 // the player's personal battle map
  381.    struct MinList icons;      // list of icons to display for his map
  382.    // eud[] & uld[] store statistics for the war report, have no effect on game
  383.    short eud[11];             // Enemy Units Destroyed
  384.    short ulc[11];             // Units Lost in Combat
  385. }; // roster[9];
  386.  
  387. struct Options {
  388.    short num_playing;         // number of players who started
  389.    BOOL stacking;             // whether stacking rules are in force
  390.    BOOL fmail;                // flag for an F-Mail game
  391.    BOOL modem;                // flag for a modem game
  392.    BOOL defend_cities;        // will units help protect a city?
  393.    BOOL entrenchment;         // can troops dig in?
  394. };
  395.  
  396. enum Direction { EAST, SOUTHEAST, SOUTHWEST, WEST, NORTHWEST, NORTHEAST };
  397.  
  398. #define PLAYER roster[player]
  399.  
  400. /*
  401.    This following structure is used with a temporary file to store all
  402.    the combat that takes place.
  403. */
  404.  
  405. struct BattleRecord {
  406.    int turn;  // turn the battle took place
  407.    int att_x, att_y;             // attacker and defender info
  408.    int att_owner, att_type;
  409.    int def_x, def_y;
  410.    int def_owner;
  411.    short white_icon, def_type;
  412.    int winner;   // who won the battle
  413.    int casualties;   // number of defending units destroyed
  414.    int bombardment;  // true if winner does not move
  415.    int seen_by;   // masks indicate who should see this report
  416.    unsigned int blows;   // stores blow-by-blow account
  417. };
  418.  
  419. /*
  420.    The use of the "blows" variable demands more explanation.  The
  421.    first byte of the value is an unsigned char from 1 to 24.  This is
  422.    the number of explosions or "blows" delivered in the fight.  The
  423.    remaining 24 bits each signify an explosion, with 1 being a hit against
  424.    the defender and 0 being a hit against the attacker.
  425. */
  426.  
  427. // automatically generated prototypes
  428. #include "main_menu_protos.h"
  429. #include "map_editor_protos.h"
  430. #include "map_editor2_protos.h"
  431. #include "graphics_protos.h"
  432. #include "map_grafx_protos.h"
  433. #include "data_struct_protos.h"
  434. #include "map_display_protos.h"
  435. #include "game_play1_protos.h"
  436. #include "game_play2_protos.h"
  437. #include "options_protos.h"
  438. #include "Gadgets_protos.h"
  439. #include "Utils_protos.h"
  440. #include "Sound.H"
  441. #include "status_protos.h"
  442. #include "cyber_protos.h"
  443.  
  444. // end of listing
  445.